package baozi;

import java.util.ArrayList;

public class BaoZiPu  extends Thread{
	ArrayList<BaoZi> basket = new ArrayList<BaoZi>();
	public BaoZiPu(String name,ArrayList<BaoZi> basket){
		super(name);
		this.basket=basket;
	}
	@Override
	public void run() {
		int count=0;
		int index = 0;
		while(true){
			synchronized (basket) {
				if(basket.size()>=5){
					try {
						basket.wait();
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
				System.out.println(getName()+"��ʼ������");
				BaoZi bz = new BaoZi();
				if(count%2==0){
					bz.pi="��Ƥ";
					bz.xier="ţ����";
				}else{
					bz.pi="��Ƥ";
					bz.xier="����";
				}
				basket.add(bz);
				count++;
				if(basket.size() == 5){
					System.out.println("���������:");
					System.out.println("�Ի� ���԰�");
					basket.notify();
				}

			}


		}
	}

}
